package com.noassertions.web;

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.noassertions.data.DAOInterface;

@Controller
public class ImageController {

	protected final Log log = LogFactory.getLog(getClass());
	private DAOInterface dao;

    @Autowired
    public ImageController(DAOInterface dao) {
        this.dao = dao;
    }  
	
	@RequestMapping("/image/{fitid}")
	public String getRider(@PathVariable Integer fitid, Model model) throws MalformedURLException, IOException
	{
		ArrayList images = dao.getImagesByFitId(fitid);
		model.addAttribute("images", images);

		return "image";
	}
}